package lex.mtd.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Timer;

import lex.mtd.utils.IReload;
import lex.mtd.utils.prefs.Prefs;

public class ReloadService {
	private static final ReloadService service = new ReloadService();

	public static ReloadService getService() {
		return service;
	}

	public void add( final IReload target )
	{
		timer.addActionListener( new ActionListener(){
			@Override
			public void actionPerformed( ActionEvent e )
			{
				target.reload();
			}
		} );
	}

	private Timer timer = null;

	private ReloadService() {
		timer = new Timer(Prefs.getUIRefreshDelay(), null);
		timer.start();
	}
}
